from langchain_community.chat_models import ChatZhipuAI
import os


# 下载zhipuai,创建密钥
os.environ["ZHIPUAI_API_KEY"] = "544d7293332c56b92739130d933f115b.x4GONk9O2pkdJFDh"
# 模型
def get_model():
    return ChatZhipuAI(
        model="glm-4",
        temperature=0.2,
        top_p=0.8,

    )


if __name__ == '__main__':

    model = get_model()
    print(model.invoke('介绍下李白'))



# #千问模型
# from openai import OpenAI
#
# def get_response(prompt):
#     client = OpenAI(
#         api_key="sk-debee146f82244268914dd2e3d98761b",
#         base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
#     )
#
#     # 获取分析结果
#     completion = client.chat.completions.create(
#         model="qwen-turbo",
#         messages=[{"role": "user", "content": prompt}],
#         temperature=0.8,
#         top_p=0.8
#     )
#
#     # 打印模型的响应
#     response_content = completion.choices[0].message.content
#
#     # 返回分析结果
#     return response_content
#
# # 定义你想提问的问题
# question = "中国的首都在哪里？"
#
# # 获取模型的回答
# answer = get_response(question)
# print(answer)
#
